package com.eliza.kotlin.design.creation.builder.demo1

/**
 * @version v1.0
 * @ClassName: Builder
 * @Description: TODO(一句话描述该类的功能)
 * @Author: 黑马程序员
 */
abstract class Builder {
    //声明Bike类型的变量，并进行赋值
    protected var bike = Bike()
    abstract fun buildFrame()
    abstract fun buildSeat()

    //构建自行车的方法
    abstract fun createBike(): Bike
}

internal class OfoBuilder : Builder() {
    override fun buildFrame() {
        bike.frame = "铝合金车架"
    }

    override fun buildSeat() {
        bike.seat = "橡胶车座"
    }

    override fun createBike(): Bike {
        return bike
    }
}

internal class MobileBuilder : Builder() {
    override fun buildFrame() {
        bike.frame = "碳纤维车架"
    }

    override fun buildSeat() {
        bike.seat = "真皮车座"
    }

    override fun createBike(): Bike {
        return bike
    }
}